home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac100% 1998 November
/
MAC100-1998-11.ISO.7z
/
MAC100-1998-11.ISO
/
オンラインソフト定点観測
/
ユーティリティ
/
Mops 3.2.sea
/
Mops 3.2
/
Mops source
/
PPC source
/
pBytestring
< prev
next >
Wrap
Text File
|
1998-02-04
|
2KB
|
116 lines
(*
The class Bytestring adds further methods to the class String+, aimed
mainly at managing strings of bytes which are arbitrary data, not
just ascii characters, and may contain non-aligned 16- or 32-bit quantities.
(Some of the fields in PEF files are good examples.)
These methods allow various numbers of bytes to be fetched from
or stored to the current position of the string, with the current
position being updated.
*)
marker m_pBytestring
:class BYTESTRING super{ string }
:m 1stW: ¥ ( -- n )
^1st: self w@ ;m
:m 1stL: ¥ ( -- n )
^1st: self @ ;m
:m >1st: ¥ ( c -- )
^1st: self c! ;m
:m >1stW: ¥ ( n -- )
^1st: self w! ;m
:m >1stL:
^1st: self ! ;m
:m nxtC: ¥ ( -- c )
1st: self 1 skip: self ;m
:m nxtW: ¥ ( -- n )
1stW: self 2 skip: self ;m
:m NXTL: ¥ ( -- n )
1stL: self 4 skip: self ;m
:m NXTN: { n -- n' }
get: self n >=
IF 0 swap n bounds DO 8 << i c@ or LOOP
n skip: self
ELSE drop 0
THEN ;m
:m >NXTC: ¥ ( c -- )
>1st: self 1 skip: self ;m
:m >NXTW: ¥ ( n -- )
>1stW: self 2 skip: self ;m
:m >NXTL: ¥ ( n -- )
>1stL: self 4 skip: self ;m
:m >NXT$: ¥ ( addr len -- )
ovwr: self ;m
:m >NXTN: { val n -- }
val pad !
4 n - pad + n >nxt$: self ;m
:m +C: ¥ ( c -- )
+: self ;m
:m +W: ¥ ( n -- )
pad w! pad 2 add: self ;m
:m +L: ¥ ( n -- )
pad ! pad 4 add: self ;m
:m +N: { n cnt -- }
n 32 cnt 2* 4* - << pad !
pad cnt add: self ;m
;class
marker m__cg1
endload
¥ =========== the current test block ============
: selectTest
SELECT[ 1 ]=>
[ 2 ]=>
[ 3 ]=> 23
[ 6 ]=> 200 200 dump
[ 9 ]=> 99 88 77
DEFAULT=> 1234
]SELECT
;
:f TEST { ¥ x -- }
dbgr
cr cr ." hi there one and all!" cr 1 2 3
begin
query cr
begin
rest nip 0>
while
defined?
if execute
else
number selectTest
then
repeat
.s cr
again
;f
:f quit test ;f ¥ temp so we can catch errors!